package cn.edu.pku.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import cn.edu.pku.dao.SalarystandardDao;
import cn.edu.pku.model.Salarystandard;

public class SalaryStandardLogicalDeleteAction {

	private SalarystandardDao salarystandardDao = null;
	
	public String execute() {
		String forward = "success";
		HttpServletRequest request = ServletActionContext.getRequest();
		String action = request.getParameter("action");
		List<Salarystandard> salarystandards = null;
		if(action.equals("getAll"))
			salarystandards = this.salarystandardDao.findDeletedSS();
		else if(action.equals("undo")) {
			int ssMgtId = Integer.parseInt(request.getParameter("ssMgtId"));
			salarystandards = this.salarystandardDao.recoverDeletedSS(ssMgtId);
		}
		else if(action.equals("delete")) {
			int ssMgtId = Integer.parseInt(request.getParameter("ssMgtId"));
			salarystandards = this.salarystandardDao.logicalDeletedSS(ssMgtId);
		}
		request.setAttribute("ssDeleted",
				salarystandards);
		return forward;
	}
	
	/**
	 * @return the salarystandardDao
	 */
	public SalarystandardDao getSalarystandardDao() {
		return this.salarystandardDao;
	}

	/**
	 * @param salarystandardDao
	 *            the salarystandardDao to set
	 */
	public void setSalarystandardDao(SalarystandardDao salarystandardDao) {
		this.salarystandardDao = salarystandardDao;
	}
}
